/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package my.StudentAdministratie;

import java.io.*;
import javax.xml.*;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.*;
import org.apache.batik.util.gui.xmleditor.XMLDocument;
import org.xml.sax.SAXException;
/**
 *
 * @author MDL
 */
public class XMLValidation {
   
    public static boolean Validate(String XMLpath, String schemaPath) throws IOException
    {
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        File schemaFile = new File(schemaPath);
        Source sourceXML = null;
        try
        {
            Schema schema = schemaFactory.newSchema(schemaFile);
            Validator validator = schema.newValidator();
            sourceXML = new StreamSource(new File(XMLpath));
            validator.validate(sourceXML);
        }
        catch(SAXException e)
        {
            return false;
        }
        return true;
    }
}
